<div class="box_right">	
	<h1>油枪管理</h1>
	<div class="pro_box layui-form">
	  <div class="order_list">
	  	<?php if (in_array('gasstation/oilgun/add_oilgun', $_SESSION['GASSTATION_ACL_ARR'])){?>
            	<a class="btn_get" style="background: #F18101;float:right;margin : 0.05in;" href="<?php echo base_url()."gasstation/oilgun/add_oilgun/"?>"><i class="icon-copy"></i>添加油枪</a>
        <?php }?>
	  	<table class="layui-table ct" lay-skin="line">
		  <thead>
			<tr>
				<th>油枪</th>
                <th>油品</th>
				<th></th>
			</tr>
		  </thead>
		  <tbody>
		  	<?php if (isset($result)&&count($result)>0){
					foreach ($result as $oilgun){
			?>
			<tr>
				<td><?php echo $oilgun->oilgun_name;?></td>
				<td style="color:#F18101;"><?php echo $oilgun->glmodel_name;?></td>
				<td>
				<?php if (in_array('gasstation/oilgun/del_oilgun', $_SESSION['GASSTATION_ACL_ARR'])){?>
					<a href="javascript:void(0)" onclick="delmodal('<?php echo $oilgun->id;?>','<?php echo $oilgun->gm_id;?>','<?php echo $oilgun->oilgun_name;?>')" data-toggle="modal" class="btn btn_get" style="background: #F18101;">修改</a>
			  	<?php }?>                  
                </td>
			</tr>
    		<?php }
            	}else{?>
			<tr>
            	<td colspan="12">无数据</td>
			</tr>
			<?php }?>
		  </tbody>
		</table>
	  </div>
	  <div class="col-sm-12">
		<div class="modal-footer no-margin-top">
			<div class="pull-left record">
				共<?php echo $count;?>条记录
				</div>
            	<?php if (isset($page))echo $page;?>
		</div>
	  </div>
	</div>
</div>
<div id="delModal" class="modal fade" role="dialog" aria-hidden="true">
  <form id="usrform" role="form" action="<?php echo base_url().'gasstation/oilgun/edit_oilgun';?>" method="post">
  <input id="oilgun_id" name="oilgun_id" type="hidden" value="">
	<div class="modal-dialog" style="width: 600px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>油枪修改</h3>
			</div>
			<div class="modal-body">
			  <table class="layui-table ct" lay-skin="line">
		  		<thead>
					<tr>
						<th>油枪号</th>
                		<th>油品</th>
					</tr>
		 		</thead>
		  	  <tbody>
				<tr>
					<td><input id="oilgun_name" name="oilgun_name" type="text" class="layui-input" style="width: 230px" placeholder="输入 ..." value="" datatype="*" nullmsg="请输入油枪号！"></td>
					<td>
						<select name="gm_id" datatype="*" nullmsg="请选择油品！" class="layui-input" style="width: 230px">
	                      <option value="">请选择油品</option>
	                        <?php foreach ($gm as $val){?>
	                      		<option id="gm_id_<?php echo $val->id;?>" name="gm_id_<?php echo $val->id;?>" value="<?php echo $val->id;?>"><?php echo $val->glmodel_name;?></option>
	                        <?php }?>
	                    </select>
	                </td>
	            </tr>
		  	  </tbody>
			</table>
			</div>
			<div class="modal-footer">
			<button id="btnSubmit" class="btn btn-get" type="submit" style="background: #F18101;color:#FFFFFF;position:relative;left:-45%;padding: 5px 20px;">确定</button>
			</div>
		</div>
	</div>
	</form>
</div>
<script>
//Demo
layui.use(['form','element','laydate'], function(){
  var form = layui.form,
  	element = layui.element,
  	laydate = layui.laydate;
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return false;
  });
});
</script>
<script type="text/javascript">
function delmodal(id,gm_id,oilgun_name){
	$("#oilgun_id").get(0).value = id;  
	$("#gm_id_"+gm_id).get(0).selected = true; 
	$("#oilgun_name").get(0).value = oilgun_name;  
    $('#delModal').modal('show');
}
</script>